<!-- Faraday Penetration Test IDE -->
<!-- Copyright (C) 2013  Infobyte LLC (http://www.infobytesec.com/) -->
<!-- See the file 'doc/LICENSE' for the license information -->

<form name="form" novalidate>
    <div class="modal-header">
        <div class="modal-button">
            <button class="btn btn-success" ng-click="ok()" ng-disabled="form.$invalid || (data.product == 'Other' && other_product == undefined) || (data.start > data.end)">OK</button>
            <button class="btn btn-danger" ng-click="cancel()">Cancel</button>
        </div>
        <h3 class="modal-title">New license</h3>
    </div>
    <div class="modal-body">
        <div class="form-horizontal">
            <div class="form-group" ng-class="{'has-error': form.product.$touched && form.product.$invalid}">
                <div class="col-md-6">
                    <label for="product">Product *</label>
                    <select name="product" class="form-control" ng-model="data.product" ng-options="product for product in products" required>
                        <option value=""></option>
                    </select>
                </div><!-- .col-md-6 -->
                <div class="col-md-3" ng-show="other" ng-class="{'has-error': data.product == 'Other' && other_product == undefined}">
                    <label for="other-product">Custom product</label>
                    <input type="text" name="other-product" class="form-control" ng-model="other_product" placeholder="Custom product name" />
                </div><!-- .col-md-3 -->
                <div class="col-md-12">
                    <p class="has-error" ng-show="(form.product.$touched && form.product.$error.required) || (data.product == 'Other' && other_product == undefined)">
                        <span class="help-block">Product name is required</span>
                    </p>
                </div><!-- .col-md-12 -->
            </div><!-- .form-group -->
            <div class="form-group">
                <div class="col-md-12">
                    <label for="lictype">Type</label>
                    <input type="text" class="form-control" name="lictype" placeholder="Type" ng-model="data.lictype" />
                </div>
            </div><!-- .form-group -->
            <div class="form-group">
                <div class="col-md-12">
                    <label for="notes">Notes</label>
                    <textarea class="form-control" name="notes" placeholder="Notes" ng-model="data.notes"></textarea>
                </div>
            </div><!-- .form-group -->
            <div class="form-group">
                <div class="col-md-6 datepicker">
                    <label for="start">Start Date *</label>
                    <p class="input-group" ng-class="{'has-error': form.start.$touched && form.start.$invalid}">
                        <input type="text" name="start" class="form-control" uib-datepicker-popup="MM/dd/yyyy" ng-model="data.start" is-open="openedStart" close-text="Close" placeholder="Start Date" required />
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default" ng-click="open($event,true)">
                                <i class="glyphicon glyphicon-calendar"></i>
                            </button>
                        </span>
                    </p>
                    <p class="help-block normal-size" ng-class="{'has-error': form.start.$touched && !form.start.$error.required && form.start.$invalid}">
                        <span class="help-block">Date format mm/dd/yyyy</span>
                    </p>
                    <p class="has-error" ng-show="form.start.$touched && form.start.$error.required">
                        <span class="help-block">Start date is required</span>
                    </p>
                </div>
                <div class="col-md-6 datepicker">
                    <label for="end">End Date *</label>
                    <p class="input-group" ng-class="{'has-error': (form.end.$touched && form.end.$invalid) || (data.start > data.end)}">
                        <input type="text" name="end" class="form-control" uib-datepicker-popup="MM/dd/yyyy" ng-model="data.end" is-open="openedEnd" min-date="data.start" close-text="Close" placeholder="End Date" required />
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default" ng-click="open($event)">
                                <i class="glyphicon glyphicon-calendar"></i>
                            </button>
                        </span>
                    </p>
                    <p class="help-block normal-size" ng-class="{'has-error': form.end.$touched && !form.end.$error.required && form.end.$invalid}">
                        <span class="help-block">Date format mm/dd/yyyy</span>
                    </p>
                    <p class="has-error" ng-show="form.end.$touched && form.end.$error.required">
                        <span class="help-block">End date is required</span>
                    </p>
                    <p class="has-error" ng-show="data.start > data.end">
                        <span class="help-block">End date must be greater than start date</span>
                    </p>
                </div>
            </div><!-- .form-group -->
            <p>All fields marked * are required</p>
        </div><!-- .form-horizontal -->
    </div><!-- .modal-body -->
    <div class="modal-footer">
        <div class="modal-button">
            <button class="btn btn-success" ng-disabled="form.$invalid || (data.product == 'Other' && other_product == undefined) || (data.start > data.end)" ng-click="ok()">OK</button>
            <button class="btn btn-danger" ng-click="cancel()">Cancel</button>
        </div>
    </div>
</form>
